﻿using System.ComponentModel;

namespace theeg.DependencyAnalysis.CommonAddin.Models
{
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        protected void SetNotifyingField<T>(ref T field, T value, string propertyName)
        {
            if (Equals(value, field)) return;
            field = value;
            RaisePropertyChanged(propertyName);
        }
    }
}
